﻿Imports System.Data
Imports System.Data.SqlClient
Imports System.Linq
Imports Microsoft.Win32
Imports System.Configuration
Namespace My

    ' The following events are available for MyApplication:
    ' 
    ' Startup: Raised when the application starts, before the startup form is created.
    ' Shutdown: Raised after all application forms are closed.  This event is not raised if the application terminates abnormally.
    ' UnhandledException: Raised if the application encounters an unhandled exception.
    ' StartupNextInstance: Raised when launching a single-instance application and the application is already active. 
    ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
    Partial Friend Class MyApplication
        Private FActiveUserID As Integer
        Private FBranchID As Integer
        Private FUserName As String
        Private FRoleID As Integer
        Public Property ActiveRoleId As Integer
            Get
                Return FRoleID
            End Get
            Set(ByVal value As Integer)
                FRoleID = value
            End Set
        End Property
        Public Property ActiveUserId As Integer
            Get
                Return FActiveUserID
            End Get
            Set(ByVal value As Integer)
                FActiveUserID = value
            End Set
        End Property
        Public Property ActiveBranchID As Integer
            Get
                Return FBranchID
            End Get
            Set(ByVal value As Integer)
                FBranchID = value
            End Set
        End Property
        Public Property ActiveUserName As String
            Get
                Return FUserName
            End Get
            Set(ByVal value As String)
                FUserName = value
            End Set
        End Property
        'Public Function Login(ByVal Username As String, ByVal Password As String) As Boolean
        '    Try
        '        Dim db As New TanNamChinhDataContext
        '        Dim query = From d In db.app_users
        '                Where d.user_name = Username And d.pass_word = Password
        '                Select d.id, d.branch_id, d.user_name, d.full_name, d.role_id

        '        Dim dt As DataTable
        '        Dim util As New Utilities
        '        dt = util.LinqToTable(db, query)
        '        For Each row As DataRow In dt.Rows
        '            With My.Application
        '                .ActiveUserId = row.Item(0)
        '                .ActiveBranchID = row.Item(1)
        '                .ActiveUserName = String.Format("({0}){1}", row.Item(2).ToString, row.Item(3).ToString)
        '                .ActiveRoleId = row.Item(4)
        '            End With


        '        Next
        '        If dt.Rows.Count > 0 Then
        '            Return True
        '        Else
        '            Return False
        '        End If
        '    Catch ex As Exception
        '        MessageBox.Show(ex.Message)
        '        Return False
        '    End Try
        'End Function
        Private Sub MyApplication_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown

        End Sub
        Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup




        End Sub
    End Class


End Namespace

